package com.fz.controller;

import com.fz.entity.RegionStore;
import com.fz.service.RegionStoreService;
import com.fz.service.StoreService;
import com.fz.vo.RegStoresVo;
import com.fz.vo.ResultVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 存储门店与区域的关联关系 前端控制器
 * </p>
 *
 * @author hyr
 * @since 2025-06-18
 */
@RestController
@RequestMapping("/regionStores")
public class RegionStoreController {
    @Resource
    StoreService storeService;
    @Resource
    RegionStoreService regionStoreService;
    @GetMapping("/getStores")
    ResultVo<RegStoresVo> getStoresList(Long regionId){
        return ResultVo.success(new RegStoresVo(storeService.getList(),regionStoreService.getByRegionId(regionId)));
    }
    @PostMapping("/save")
    ResultVo<Boolean> save(Long regionId, Long[] storesIds){
        return ResultVo.success(regionStoreService.save(regionId,storesIds));
    }
    @GetMapping("/list")
    public ResultVo<List<RegionStore>> listAllRegionStores() {
        return ResultVo.success(regionStoreService.list());
    }
}
